#include "gd32f4xx.h"  
#include "gpio.h"  
#include "main.h"  
#include "speed_cntr.h"  
#include "systick.h"  
#include "tim.h"  
#include "usart.h"  
#include "user_device.h"  
#include "wwdg.h"
#include <setjmp.h>
#include <stdio.h>


extern jmp_buf main_loop_env;
int main(void)
{
    systick_config();
    MX_GPIO_Init();
    MX_USART1_UART_Init();
    MX_USART2_UART_Init();
    MX_TIM0_Init();
    MX_TIM1_Init();
    MX_TIM2_Init();
    MX_TIM3_Init();
    MX_TIM5_Init();
    MX_TIM6_Init();
    MX_TIM7_Init();
    MX_TIM8_Init();
    MX_TIM9_Init();
    MX_TIM11_Init();
    MX_TIM13_Init();
    MX_TIM12_Init();
    Device_Init();
#if USE_WATCHDG
    MX_WWDG_Init();
#endif
    setjmp(main_loop_env);
    while (1)
    {
        Main_Loop();

        if (pending_action)
        {
            pending_action = 0;
            Process_Action();
        }

        Process_Start_Event(KEY_STARTL);
        Process_Start_Event(KEY_STARTR);
        Process_Rack(KEY_STARTL);
        Process_Rack(KEY_STARTR);
        Key_Led_Ctrl(KEY_STARTL);
        Key_Led_Ctrl(KEY_STARTR);
    }
}
